package JUnitTest;

import static org.junit.Assert.*;
import org.junit.AfterClass;
import org.junit.After;
import org.junit.Before;

import org.junit.Test;

public class EnCapTest {
	
	@Before
	public void setUp() 
	{
	}
	@After
	public void tearDown() 
	{
	}
	
	@Test
	public void testGetName() 
	{
	        System.out.println("getName");        
	        EnCap instance = new EnCap();
	        instance.setName("i");
	        String expResult = "John Doe";
	String result = instance.getName();
	assertEquals(expResult, result);
	
	System.out.println(instance.getName());
	}
	
	@Test
	public void testSetName() 
	{
	        System.out.println("setName");
	// test of name 1 character long
	String name = "I";
	EnCap instance = new EnCap();
	instance.setName(name);
	String expResult = "John Doe";
	String result = instance.getName();
	assertEquals(expResult, result);
	                
	         // test of name longer  than 29 characters
	name = "Ivan the very mighty warrior from the land with the long names";
	         instance.setName(name);
	         expResult = "John Doe";
	        result = instance.getName();
	assertEquals(expResult, result);
	// test of name longer than 1 character and less than 30 characters
	         name = "Ivan";      
	        instance.setName(name);
	         expResult = "Ivan";
	        result = instance.getName();
	        assertEquals("setName long name " , expResult, result);
	    }
	/**
     * Test of getAge method, of class Encap.
*/
    @Test
    public void testGetAge() 
    {
        System.out.println("getAge");
        EnCap instance = new EnCap();
        instance.setAge(21);       
        int expResult = 21;
        int result = instance.getAge();
        assertEquals(expResult, result);
        System.out.println(instance.getAge());
    }
    //tester age under 18
    @Test 
    public void testSetAge(){
    	System.out.println("setAge");
    	EnCap instance = new EnCap();
    	instance.setAge(17);
    	int expResult = 0;
    	int result = instance.getAge();
    	assertEquals(expResult,result);
    	System.out.println(instance.getAge());
    	
    //tester age over 99
    	instance.setAge(160);
    	expResult = 0;
    	result = instance.getAge();
    	assertEquals(expResult,result);
    	System.out.println(instance.getAge());
    	
    	
    	//tester age over 18 og under 99
    	instance.setAge(55);
    	expResult = 55;
    	result = instance.getAge();
    	assertEquals(expResult,result);
    	System.out.println(instance.getAge());
    }
    
    
    
    


	
	
}
